package servlets;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dbmanager.MSSQL;
import dbmanager.SQLManager;
import domain.UCET;

@WebServlet("/NovyUcetServlet2")
public class NovyUcetServlet2 extends HttpServlet {
	
	private static final long serialVersionUID = 1L;
       
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String idk = request.getParameter("idk");
		String idp = request.getParameter("idp");
		String vklad = request.getParameter("poc_vklad");
		
		UCET novy = new UCET(null, Integer.decode(idk), Integer.decode(idp),null, null, Double.valueOf(vklad));
		
		MSSQL ms = new MSSQL("127.0.0.1");
		SQLManager s = ms.connect();
		
		s.insertN(novy,"BA");
		ms.disconnect(s.getConnection());
		
		response.sendRedirect("default.html");
	}
}
